package game.zqll.systems;

import com.artemis.BaseSystem;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import game.zqll.ModSampleApplication;
import game.zqll.PluginFileHandle;

public class BackgroundRenderSystem extends BaseSystem {

    private CameraSystem cameraSystem;
    private final SpriteBatch spriteBatch;
    private final TextureRegion backgroundRegion;

    public BackgroundRenderSystem() {
        this.spriteBatch = new SpriteBatch();
        this.backgroundRegion = new TextureRegion(new Texture(new PluginFileHandle("background.png")));
    }

    @Override
    protected void processSystem() {
        spriteBatch.begin();
        spriteBatch.setProjectionMatrix(cameraSystem.getCamera().combined);
        spriteBatch.draw(backgroundRegion, 0, 0, ModSampleApplication.worldWidth, ModSampleApplication.worldHeight);
        spriteBatch.end();
    }
}
